<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/html"><head>
	    <meta charset="utf-8">
    <title>ThinkPHP5.0</title>

    <meta name="description" content="Dashboard">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <!--Basic Styles-->
    <link href="__STATIC__/admin/style/bootstrap.css" rel="stylesheet">
    <link href="__STATIC__/admin/style/font-awesome.css" rel="stylesheet">
    <link href="__STATIC__/admin/style/weather-icons.css" rel="stylesheet">

    <!--Beyond styles-->
    <link id="beyond-link" href="__STATIC__/admin/style/beyond.css" rel="stylesheet" type="text/css">
    <link href="__STATIC__/admin/style/demo.css" rel="stylesheet">
    <link href="__STATIC__/admin/style/typicons.css" rel="stylesheet">
    <link href="__STATIC__/admin/style/animate.css" rel="stylesheet">

    <script src="__STATIC__/admin/style/jquery_002.js"></script>
    <script src="__STATIC__/admin/plus/uploadify/jquery.uploadify.min.js"></script>
    <script src="__STATIC__/admin/plus/layer/layer.js"></script>

    <script src="__STATIC__/admin/ueditor/ueditor.config.js"></script>
    <script src="__STATIC__/admin/ueditor/ueditor.all.min.js"></script>
    <script src="__STATIC__/admin/ueditor/lang/zh-cn/zh-cn.js"></script>
    <script type="text/javascript">
        $(function () {
            $("#uploadify").uploadify({
                //插件自带  不可忽略的参数
                'swf': "__STATIC__/admin/plus/uploadify/uploadify.swf",
                //前台请求后台的url 不可忽略的参数
                'uploader':"{:url('Content/upimg')}",
                'progressData':'speed',
                //给上传按钮设置文字
                'buttonText': '上传文件',
                'buttonClass':'btn btn-azure',
                'fileTypeDesc': 'Image Files',
                //设定发送数据的name
                'fileObjName':'img',
                'onUploadSuccess':function (file,data,response) {
                    $("input[name='img']").val(data);
                    var imgsrc="/uploads/index/"+data;
                    var img="<img height='100' src='"+imgsrc+"'>";
                    $("#img").html(img);
                }
            });
            $("#uploadify-button").removeAttr('style');
        });
    </script>
    
</head>
<body>
	<!-- 头部 -->
    {include file="common/head"}
	<!-- /头部 -->
	
	<div class="main-container container-fluid">
		<div class="page-container">
            {include file="common/left"}
            <!-- /Page Sidebar -->
            <!-- Page Content -->
            <div class="page-content">
                <!-- Page Breadcrumb -->
                <div class="page-breadcrumbs">
                    <ul class="breadcrumb">
                                        <li>
                        <a href="{:url('index/index')}">系统</a>
                    </li>
                                        <li>
                        <a href="{:url('content/index')}">文档管理</a>
                    </li>
                                        <li class="active">添加文档</li>
                                        </ul>
                </div>
                <!-- /Page Breadcrumb -->

                <!-- Page Body -->
                <div class="page-body">
                    
<div class="row">
    <div class="col-lg-12 col-sm-12 col-xs-12">
        <div class="widget">
            <div class="widget-header bordered-bottom bordered-blue">
                <span class="widget-caption">新增文档</span>
            </div>
            <div class="widget-body">
                <div id="horizontal-form">
                    <form class="form-horizontal" role="form" action="" method="post">
                        <div class="form-group">
                            <label  class="col-sm-2 control-label no-padding-right">标题</label>
                            <div class="col-sm-6">
                                <input class="form-control"  placeholder="" name="title" required="" type="text">
                            </div>
                            <p class="help-block col-sm-4 red">* 必填</p>
                        </div>
                        <div class="form-group">
                            <label  class="col-sm-2 control-label no-padding-right">属性</label>
                            <div class="col-sm-6">
                                <div class="checkbox" style="float: left;padding-left: 10px">
                                <label>
                                       <input name="attr[]" value="头条" class="colored-blue" type="checkbox">
                                       <span class="text">头条</span>
                                </label>
                                </div>
                                <div class="checkbox" style="float: left;padding-left: 10px">
                                    <label>
                                        <input name="attr[]"  value="推荐" class="colored-blue" type="checkbox">
                                        <span class="text">推荐</span>
                                    </label>
                                </div>
                                <div class="checkbox" style="float: left;padding-left: 10px">
                                <label>
                                    <input name="attr[]"  value="幻灯" class="colored-blue" type="checkbox">
                                    <span class="text">幻灯</span>
                                </label>
                            </div>
                                <div class="checkbox" style="float: left;padding-left: 10px">
                                <label>
                                    <input name="attr[]"  value="加粗<" class="colored-blue" type="checkbox">
                                    <span class="text">加粗</span>
                                </label>
                            </div>
                                <div class="checkbox" style="float: left;padding-left: 10px">
                                    <label>
                                        <input name="attr[]"  value="图片" class="colored-blue" type="checkbox">
                                        <span class="text">图片</span>
                                    </label>
                                </div>


                            </div>

                        </div>
                        <div class="form-group">
                            <label  class="col-sm-2 control-label no-padding-right">所属栏目</label>
                            <div class="col-sm-6">

                                    {volist name="cateRes" id="cate"}
                                    {if condition="$cate['id'] eq $cateId"}
                                    <span class="form-control">{$cate.cate_name}</span>
                                     <input type="hidden" name="cate_id" value="{$cate.id}">
                                    {/if}
                                    {/volist}

                            </div>
                            <p class="help-block col-sm-4 red">* 必填</p>
                        </div>
                        <div class="form-group">
                            <label  class="col-sm-2 control-label no-padding-right">关键词</label>
                            <div class="col-sm-6">
                                <input class="form-control"  placeholder="" name="keywords" required="" type="text">
                            </div>
                        </div>
                        <div class="form-group">
                            <label  class="col-sm-2 control-label no-padding-right">描述</label>
                            <div class="col-sm-6">
                              <textarea class="form-control" name="description" ></textarea>
                            </div>
                        </div>
                        <div class="form-group">
                            <label  class="col-sm-2 control-label no-padding-right">作者</label>
                            <div class="col-sm-6">
                                <input class="form-control"  placeholder="" name="writer" required="" type="text">
                            </div>
                        </div>
                        <div class="form-group">
                            <label  class="col-sm-2 control-label no-padding-right">来源</label>
                            <div class="col-sm-6">
                                <input class="form-control"  placeholder="" name="source" required="" type="text">
                            </div>
                        </div>
                        <div class="form-group">
                            <label  class="col-sm-2 control-label no-padding-right">栏目图片</label>
                            <div class="col-sm-6">
                                <label>
                                    <span  id="uploadify"></span>
                                    <span class="text"></span>
                                    <input value="" name="img" type="hidden">
                                </label>
                                <label>
                                    <div id="cancel" class="uploadify-button btn btn-azure">
                                        <span class="uploadify-button-text"><i class="fa fa-rotate-left">撤销上传</i></span></div>
                                </label>
                            </div>
                        </div>

                        <div id="img" style="padding-left: 180px;"></div>
                       <!-- 自定义开始-->
                        <?php foreach($diyFields as $k=>$v): ?>
                        <div class="form-group">
                            <label  class="col-sm-2 control-label no-padding-right"><?php echo $v['field_cname'] ?></label>
                            <div class="col-sm-6">
                               <?php switch ($v['field_type']){
                                case 1:
                                case 7:
                                case 8:echo "<input type='text' name='".$v['field_ename']."' class='form-control' >";
                                break;
                                case 5: echo "<textarea  name='".$v['field_ename']."' class='form-control' ></textarea>";
                                break;
                                case 2:
                                if($v['field_values']){
                                   $arr=explode(',',$v['field_values']);
                                  foreach($arr as $k1=>$v1){
                                   echo "<div class='radio' style='float: left;padding-left: 10px' >";
                                   echo "<label>";
                                   echo "<input type='radio' name='".$v['field_ename']."' value='".$v1."';
                                   class='colored-blue' >";
                                   echo "<span class='text'> $v1</span>";
                                   echo "</label>";
                                   echo  "</div>";
                                  }
                                }
                                break;
                                case 3:
                                if($v['field_values']){
                                    $arr=explode(',',$v['field_values']);
                                  foreach($arr as $k1=>$v1){
                                     echo "<div class='checkbox' style='float: left;padding-left: 10px' >";
                                     echo "<label >";
                                     echo "<input type='checkbox' name='".$v['field_ename']."[]' value='".$v1."';
                                     class='colored-blue' >";
                                     echo "<span class='text'> $v1</span>";
                                     echo "</label>";
                                     echo  "</div>";
                                  }
                                }
                                break;

                                case 9: echo get_ueditor($v['field_ename']);
                                break;
                                default: echo "<input type='text' name='".$v['field_ename']."' class='form-control' >";
                                break;
                                }?>
                            </div>
                        </div>
                        <?php endforeach;?>
                        <!--自定义结束-->

                        <div class="form-group">
                            <label  class="col-sm-2 control-label no-padding-right">内容</label>
                            <div class="col-sm-6">
                                <textarea id="content" name="content"  ></textarea>
                            </div>
                        </div>
                        <div class="form-group">
                            <label  class="col-sm-2 control-label no-padding-right">点击数</label>
                            <div class="col-sm-6">
                                <input class="form-control"  placeholder="" name="click" required="" type="text">
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-sm-offset-2 col-sm-10">
                                <button type="submit" class="btn btn-default">保存信息</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>

                </div>
                <!-- /Page Body -->
            </div>
            <!-- /Page Content -->
		</div>	
	</div>

	    <!--Basic Scripts-->

    <script src="__STATIC__/admin/style/bootstrap.js"></script>
    <script src="__STATIC__/admin/style/jquery.js"></script>
    <!--Beyond Scripts-->
    <script src="__STATIC__/admin/style/beyond.js"></script>
    <script type="text/javascript">

        //实例化编辑器
        //建议使用工厂方法getEditor创建和引用编辑器实例，如果在某个闭包下引用该编辑器，直接调用UE.getEditor('editor')就能拿到相关的实例
        UE.getEditor('content',{ toolbars:[
            [
                'fullscreen', 'source', '|', 'undo', 'redo', '|',
                'bold', 'italic', 'underline', 'fontborder', 'strikethrough', 'superscript', 'subscript', 'removeformat', 'formatmatch', 'autotypeset', 'blockquote', 'pasteplain', '|', 'forecolor', 'backcolor', 'insertorderedlist', 'insertunorderedlist', 'selectall', 'cleardoc', '|',
                'rowspacingtop', 'rowspacingbottom', 'lineheight', '|',
                'customstyle', 'paragraph', 'fontfamily', 'fontsize', '|',
                'directionalityltr', 'directionalityrtl', 'indent', '|',
                'justifyleft', 'justifycenter', 'justifyright', 'justifyjustify', '|', 'touppercase', 'tolowercase', '|',
                'link', 'unlink', 'anchor', '|', 'imagenone', 'imageleft', 'imageright', 'imagecenter', '|',
                'simpleupload', 'insertimage', 'emotion', 'scrawl', 'insertvideo', 'music', 'attachment', 'map', 'gmap', 'insertframe', 'insertcode'
            ]
        ], initialFrameWidth:680,initialFrameHeight:300,});
/*
        <?php foreach($longTextFields as $k => $v):?>
        UE.getEditor('<?php echo $v['field_ename'];?>',{ toolbars:[
            [
                'fullscreen', 'source', '|', 'undo', 'redo', '|',
                'bold', 'italic', 'underline', 'fontborder', 'strikethrough', 'superscript', 'subscript', 'removeformat', 'formatmatch', 'autotypeset', 'blockquote', 'pasteplain', '|', 'forecolor', 'backcolor', 'insertorderedlist', 'insertunorderedlist', 'selectall', 'cleardoc', '|',
                'rowspacingtop', 'rowspacingbottom', 'lineheight', '|',
                'customstyle', 'paragraph', 'fontfamily', 'fontsize', '|',
                'directionalityltr', 'directionalityrtl', 'indent', '|',
                'justifyleft', 'justifycenter', 'justifyright', 'justifyjustify', '|', 'touppercase', 'tolowercase', '|',
                'link', 'unlink', 'anchor', '|', 'imagenone', 'imageleft', 'imageright', 'imagecenter', '|',
                'simpleupload', 'insertimage', 'emotion', 'scrawl', 'insertvideo', 'music', 'attachment', 'map', 'gmap', 'insertframe', 'insertcode'
            ]
        ], initialFrameWidth:680,initialFrameHeight:300,});
        <?php endforeach; ?>*/

        $("#cancel").click(function () {
//        var cateimg=$("#cateimg").find("img");
            var imgurl= $("input[name='img']").val();
            if(!imgurl){
                layer.msg('请先上传图片',{icon:2})
                return false;
            }
            layer.confirm('确定要撤销图片吗?', {icon: 3, title:'提示'}, function(index){
                $('#img').hide();
                $("input[name='img']").val('');
                $.ajax({
                    type:"post",
                    dataType:"json",
                    data:{imgurl:imgurl},
                    url:"{:url('Content/delImg')}",
                    success:function (data) {
                        if (data==1){
                            layer.msg('撤销成功!',{icon:1})
                        }else {
                            layer.msg('撤销失败!',{icon:2})
                        }
                    }
                });
                layer.close(index);
            });
        });
        </script>


</body></html>